<?php
	/**
	 * 背包列表
	 */
    class BackPack extends APIBase {
		
		public $tag = "BackPack";
    	public $isLogin = true;
		
		public function before() {
			$this->initCacheRedis();
			$this->initMysql();
			return true;
		}
		public function logic(){
			$playerID = $this->uid;
			$type = $this->param['type'];
			//背包列表
			$backpacklist = $this->cache_redis->keys("hbackpack:$playerID:*");
			//道具列表
			$proplist = $this->cache_redis->keys("prop:*");
            $count = count($backpacklist);
			$backpackArr = array();
			for($i=0;$i<$count;$i++){
				$backpack = $this->cache_redis->hGetAll("hbackpack:$playerID:".$i);
				if($type==1){//普通道具
				    if($backpack['type']==1){
						if($backpack['propid']==1){
							$num = $this->data_redis->hGet("hu:".$playerID,"room_card");
						}else{
							$num = $this->data_redis->hGet("hu:".$playerID,"room_card_coop");
						}
						$prop = $this->cache_redis->hGetAll("prop:".$backpack['propid']);
						$backpackArr[] = array('uid'=>$backpack['uid'],'propname'=>$prop['name'],'count'=>$num,'propid'=>$backpack['propid'],'type'=>$backpack['type']);
					} 
			    }elseif($type==3){//动作道具
				    if($backpack['type']==3){
						$prop = $this->cache_redis->hGetAll("prop:".$backpack['propid']);
						$backpackArr[] = array('uid'=>$backpack['uid'],'propname'=>$prop['name'],'count'=>$backpack['count'],'propid'=>$backpack['propid'],'type'=>$backpack['type']);
					}
			    }elseif($type==4){//表情道具
				    if($backpack['type']==4){
						$prop = $this->cache_redis->hGetAll("prop:".$backpack['propid']);
						$backpackArr[] = array('uid'=>$backpack['uid'],'propname'=>$prop['name'],'count'=>$backpack['count'],'propid'=>$backpack['propid'],'type'=>$backpack['type']);
					}
			    }else{//场景道具
				    if($backpack['type']==5){
						$prop = $this->cache_redis->hGetAll("prop:".$backpack['propid']);
						$backpackArr[] = array('uid'=>$backpack['uid'],'propname'=>$prop['name'],'count'=>$backpack['count'],'propid'=>$backpack['propid'],'type'=>$backpack['type']);
					}
			    }
			}
			$this->returnData($backpackArr);
		}
		
        public function after() {
			$this->deinitCacheRedis();
		}
    }
?>
